package cn.liuding.pethome.basic.base.service.impl;

import cn.liuding.pethome.basic.base.mapper.BaseMapper;
import cn.liuding.pethome.basic.base.query.BaseQuery;
import cn.liuding.pethome.basic.base.service.IBaseService;
import cn.liuding.pethome.basic.util.PageList;
import cn.liuding.pethome.org.query.DepartmengQuery;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

public class BaseServiceImpl<T> implements IBaseService<T> {
    @Autowired
    private BaseMapper<T> baseMapper;

    @Override
    public void add(T t) {
        baseMapper.add(t);
    }

    @Override
    public void update(T t) {
        baseMapper.update(t);
    }

    @Override
    public void delete(Long id) {
        baseMapper.delete(id);
    }

    @Override
    public T loadById(Long id) {
        return (T) baseMapper.loadById(id);
    }

    @Override
    public List<T> loadAll() {
        return baseMapper.loadAll();
    }

    @Override
    public PageList<T> pageList(BaseQuery query) {
        Long total = baseMapper.queryCount(query);
        List list = baseMapper.queryData(query);
        return new PageList<T>(list,total);
    }

    @Override
    public void deleteAll(List ids) {
        baseMapper.deleteAll(ids);
    }
}
